@(backReference: String)

var S3Index = {
    
  JSONP : {
    currentScript : null,
    getJSON : function(url, callback, data) {
      var src = url + (url.indexOf("?") + 1 ? "&" : "?");
      var head = document.getElementsByTagName("head")[0];
      var newScript = document.createElement("script");
      var params = [];
      var param_name = ""

      this.success = callback;

      data["callback"] = "S3Index.JSONP.success";
      for (param_name in data) {
        params.push(param_name + "=" + encodeURIComponent(data[param_name]));
      }
      src += params.join("&")

      newScript.type = "text/javascript";
      newScript.src = src;

      if (this.currentScript)
        head.removeChild(currentScript);
      head.appendChild(newScript);
    },
    success : null
  },
  
  ie : function(){
    var undef,
        v = 3,
        div = document.createElement('div'),
        all = div.getElementsByTagName('i');
 
    while (
        div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
        all[0]
    );
    return v > 4 ? v : undef;
  },
  
  init: function(properties){
   if (!("onhashchange" in window) || S3Index.ie() || S3Index.ie < 8)  {
        var prevHash = window.location.hash;
        var oldHref = location.href;
        window.setInterval(function() {
            var newHref = location.href;
            if (oldHref !== newHref) {
                oldHref = newHref;
                S3Index.load(properties);
            }
        }, 100);
    } else if (window.addEventListener) {
      window.addEventListener("hashchange", function(){S3Index.load(properties)}, false);
    } else if (window.attachEvent) {
      window.attachEvent("onhashchange", function(){S3Index.load(properties)});    
    }
    S3Index.load(properties)
  },
  
  load: function(properties) {
    if(!properties) return;
    properties['prefix'] = S3Index.prefix(window.location.hash);
    properties['marker'] = S3Index.marker(window.location.hash) || '1';
    S3Index.JSONP.getJSON("@backReference/jsonp", function(data) {
      document.getElementById('s3index-root').innerHTML = data.html
    }, properties  );    
  },
  
  prefix: function(hash){
	  var prefixRegexp = /[#]([^&]+)/;
	  if(prefixRegexp.test(hash)) {
      var matches = hash.match(prefixRegexp);
      return matches[1];
    } else {
      return '';
    }
  },
  
  marker: function(hash){
    var markerRegexp = /[&]([^&]+)/;
    if(markerRegexp.test(hash)) {
      var matches = hash.match(markerRegexp);
      return matches[1];
    } else {
      return '';
    }
  }
  
};